<ul class="nav nav-tabs nav-tabs-alt" data-toggle="tabs" role="tablist">
    <li class="nav-item">
        <a class="nav-link active" href="#tab1">基本信息</a>
    </li>
    <li class="nav-item">
        <a class="nav-link" href="#tab2">正文</a>
    </li>
</ul>
<div class="block-content tab-content block-content-full">
    <div class="tab-pane active" id="tab1" role="tabpanel">
        <div class="form-group row">
            {!! Form::label('title', '标题:', ['class' => 'col-form-label col-sm-1']) !!}
            <div class="col-sm-5">
                {!! Form::text('title', null, ['class' => 'form-control', 'required']) !!}
            </div>
            {!! Form::label('category_id', '分类:', ['class' => 'col-form-label col-sm-1']) !!}
            <div class="col-sm-5">
                {!! Form::select('category_id', array_prepend($categories, '无', 0), $article->category_id ?? 0, ['class' => 'form-control']) !!}
            </div>
        </div>
        <div class="form-group row">
            {!! Form::label('tags', '标签:', ['class' => 'col-form-label col-sm-1']) !!}
            <div class="col-sm-11">
                {!! Form::text('tags', null, ['class' => 'form-control tags']) !!}
            </div>
        </div>

        <div class="form-group row">
            {!! Form::label('author', '作者:', ['class' => 'col-form-label col-sm-1']) !!}
            <div class="col-sm-5">
                {!! Form::text('author', null, ['class' => 'form-control']) !!}
            </div>
            {!! Form::label('source', '内容来源:', ['class' => 'col-form-label col-sm-1']) !!}
            <div class="col-sm-5">
                {!! Form::text('source', null, ['class' => 'form-control']) !!}
            </div>
        </div>

        <div class="form-group row">
            {!! Form::label('summary', '摘要:', ['class' => 'col-form-label col-sm-1']) !!}
            <div class="col-sm-11">
                {!! Form::textarea('summary', null, ['class' => 'form-control', 'rows' => '4']) !!}
            </div>
        </div>
        <div class="form-group row">
            {!! Form::label('list_image_url', '列表图:', ['class' => 'col-form-label col-sm-1']) !!}
            <div class="col-sm-5">
                {!! Form::text('list_image_url', null, ['class' => 'form-control']) !!}
            </div>
        </div>
        <div class="form-group row">
            <label for="list_image_file" class="col-form-label col-sm-1">上传列表图:</label>
            <div class="col-sm-5">
                <div class="file-loading">
                    <input id="list_image_file" name="list_image_file" type="file" class="file"  data-upload-url="/common/file/upload?type=image">
                </div>
            </div>
        </div>
    </div>
    <div class="tab-pane" id="tab2" role="tabpanel">
        <div class="form-group row">
            <div class="col-sm-12">
                {!! Form::textarea('content', null, ['id' => 'content', 'class' => 'form-control editor', 'required']) !!}
            </div>
        </div>
    </div>

</div>
<div class="block-footer">
    <button type="button" class="btn btn-default" onclick="history.go(-1)">取　消</button>
    <button type="submit" class="btn btn-primary">确　定</button>
</div>

@section('js_after')
    @include('vendor.fileinput.assets')
    @include('vendor.ueditor.assets')
    @include('vendor.tagsinput.assets')


    <script type="text/javascript">
        $(function () {
            $('input.tags').tagsInput();
        });

        //列表图
        $("#list_image_file").fileinput({
            language: 'zh',
            theme: 'fa',
            uploadExtraData: {_token: '{{ csrf_token() }}'},
            browseClass: "btn btn-primary",
            allowedFileExtensions: ['jpg', 'png', 'gif'],
            maxFileSize: 4096,
            maxFileCount: 1,
            deleteUrl: '/common/file/delete?_token={{csrf_token()}}',
            overwriteInitial: false,
            initialPreviewAsData: true,
            initialPreview: [
                $('#list_image_url').val(),
            ],
            initialPreviewConfig: [
                {width: "240px",  key: 1},
            ]
        }).on("fileuploaded", function(event, data, previewId, index) {
            $('#list_image_url').val(data.response.data);
        }).on("fileclear",function(event, data, msg){
            $('#list_image_url').val('');
        }).on("filereset",function(event, data, msg){
            $('#list_image_url').val('');
        });

    </script>

    <!-- 实例化编辑器 -->
    <script type="text/javascript">
        var ue = UE.getEditor('content');
        ue.ready(function() {
            ue.execCommand('serverparam', '_token', '{{ csrf_token() }}'); // 设置 CSRF token.
        });

    </script>

@endsection

